<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title">
		<h2>{$main_title}</h2>
	</div>
	<div class="cf">
		<div class="fl">
            <button class="btn ajax-post" url="{:U('Attendence/audit',array('status'=>'1'))}" target-form="ids">批 准</button>
            <button class="btn ajax-post" url="{:U('Attendence/audit',array('status'=>'-1'))}" target-form="ids">驳 回</button>
            <button class="btn ajax-post confirm" url="{:U('Attendence/audit',array('method'=>'delete'))}" target-form="ids">删 除</button>
        </div>

        <!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
				<div class="drop-down">
					<span id="sch-sort-txt" class="sort-txt" data="{$status}"><if condition="get_status_title($status) eq ''">所有<else/>{:get_status_title($status)}</if></span>
					<i class="arrow arrow-down"></i>
					<ul id="sub-sch-menu" class="nav-list hidden">
						<li><a href="javascript:;" value="">所有</a></li>
						<li><a href="javascript:;" value="1">通过</a></li>
						<li><a href="javascript:;" value="0">待审核</a></li>
						<li><a href="javascript:;" value="-1">被驳回</a></li>
					</ul>
				</div>
				<input type="text" name="uid" class="search-input" value="{:I('uid')}" placeholder="请输入用户UID">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('audit',false)}"><i class="btn-search"></i></a>
			</div>
            <div class="btn-group-click adv-sch-pannel fl">
                <button class="btn">高 级<i class="btn-arrowdown"></i></button>
                <div class="dropdown cf">
                	<div class="row">
                		<label>更新时间：</label>
                		<input type="text" id="time-start" name="time-start" class="text input-2x" value="" placeholder="起始时间" /> -
                		<input type="text" id="time-end" name="time-end" class="text input-2x" value="" placeholder="结束时间" />
                	</div>
                	
                </div>
            </div>
		</div>
		
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
			<thead>
				<tr>
					<th class="row-selected row-selected"><input class="check-all" type="checkbox"></th>
					<th class="">UID</th>
					<th class="">姓名</th><!---
					<th class="">职位</th>
					<th class="">部门</th>-->
					<th class="">请假缘由</th>
					<th class="">开始时间</th>
					<th class="">结束时间</th> 
					<th class="">当前状态</th>
					<th class="">操作</th> 
				</tr>
			</thead>
			<tbody>
			<volist name="list" id="vo">
				<tr>
					<td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}"></td>
					<td>{$vo.uid}</td>
					<td>{$vo.uid|get_nickname_from_uid}</td><!---
					<td>{$vo.position}</td>
					<td>{$vo.department}</td>-->
					<td>{$vo.reason}</td>
					<td>{$vo.absence_time|time_to_date}</td>
					<td>{$vo.attendence_time|time_to_date}</td>
					<td>{$vo.status|get_attendence_status_info}</td>
					<td><a href="{$vo.approve}" class="confirm ajax-get ">批准</a>
						<a href="{$vo.oppose}" class="confirm ajax-get ">驳回</a>
					</td>
				</tr>
			</volist>
			</tbody>
		</table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
	<php>echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
	<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">

	<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
	<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

	<script type="text/javascript">
	
    //导航高亮
    $('.side-sub-menu').find('a[href="{:U('User/index')}"]').closest('li').addClass('current');
	$(function(){
		$('.attendence_time').datetimepicker({
		  pickDate: false
		});
		
		$('.attendence_time').bind('input propertychange', function() {
			alert('start');
			if($(this).val() != ''){
				alert('start');
				var url = $(this).attr('data-url');
				var time = $(this).val();
				$.getJSON(url,{attendence_time:time},function(json){
					if(json.status == 1){
						alert('success');
					}else{
						alert('fail');
					}
				});
			}else{
				alert('q12');
			}
		});
		//搜索功能
		$("#search").click(function(){
			var url = $(this).attr('url');
			var status = $("#sch-sort-txt").attr("data");
			var query  = $('.search-form').find('input').serialize();
			query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
			query = query.replace(/^&/g,'');
			if(status != ''){
				query += 'status=' + status + "&" + query;
			}
			if( url.indexOf('?')>0 ){
				url += '&' + query;
			}else{
				url += '?' + query;
			}
			window.location.href = url;
		});

		/* 状态搜索子菜单 */
		$(".search-form").find(".drop-down").hover(function(){
			$("#sub-sch-menu").removeClass("hidden");
		},function(){
			$("#sub-sch-menu").addClass("hidden");
		});
		$("#sub-sch-menu li").find("a").each(function(){
			$(this).click(function(){
				var text = $(this).text();
				$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
				$("#sub-sch-menu").addClass("hidden");
			})
		});

		//回车自动提交
		$('.search-form').find('input').keyup(function(event){
			if(event.keyCode===13){
				$("#search").click();
			}
		});

		$('#time-start').datetimepicker({
			format: 'yyyy-mm-dd',
			language:"zh-CN",
			minView:2,
			autoclose:true
		});

		$('#time-end').datetimepicker({
			format: 'yyyy-mm-dd',
			language:"zh-CN",
			minView:2,
			autoclose:true
		});
	});
	</script>
</block>
